import { message } from "ant-design-vue";
import { updateLogisticsApi } from "@/api/waybillManagement/customerServiceWaybill/index";
export default function OperationHook(state: any) {
  const { passData, formState, loading, formDataRef, emit } = state;
  const onSubmit = () => {
    loading.value = true;
    const params = {
      ...formState,
      id: passData.value.id
    };
    updateLogisticsApi(params)
      .then((res: any) => {
        const { code } = res;
        if (code === 200) {
          message.success("操作成功!");
          formDataRef.value.resetFields();
          emit("submit");
        }
      })
      .finally(() => {
        loading.value = false;
      });
  };
  const resetForm = () => {
    formDataRef.value.resetFields();
    emit("update:visible", false);
  };
  return {
    onSubmit,
    resetForm
  };
}
